﻿using System;
using System.Collections.Generic;

public enum ViewDefine
{
    MainGameView,
}

public enum ItemDefine
{
    HPBarItem,
    HUDItem,
}

public class UIMap
{
    public Type mType;
    public string mPath;

    public UIMap(Type type, string path)
    {
        mType = type;
        mPath = path;
    }
}

public class ViewMapping
{
    static List<UIMap> ViewMap = new List<UIMap>();
    static List<UIMap> ItemMap = new List<UIMap>();

    static void AddMap(ViewDefine key, string path)
    {
        Type type = Type.GetType(key.ToString());
        ViewMap.Add(new UIMap(type, path));
    }

    static void AddMap(ItemDefine key, string path)
    {
        Type type = Type.GetType(key.ToString());
        ItemMap.Add(new UIMap(type, path));
    }

    public static UIMap GetMap(ViewDefine key)
    {
        int index = (int)key;
        if (ViewMap.Count > index)
            return ViewMap[index];
        return null;
    }

    public static UIMap GetMap(ItemDefine key)
    {
        int index = (int)key;
        if (ItemMap.Count > index)
            return ItemMap[index];
        return null;
    }

    static ViewMapping()
    {
        InitViews();
        InitItems();
    }

    static void InitViews()
    {
        AddMap(ViewDefine.MainGameView, "main/MainGamePanel");
    }

    static void InitItems()
    {
        AddMap(ItemDefine.HPBarItem, "items/HPBarItem");
        AddMap(ItemDefine.HUDItem, "items/HUDItem");
    }
}
